
import { _decorator, Component, Node, Graphics,toRadian  } from 'cc';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = Dian
 * DateTime = Thu Apr 14 2022 20:22:33 GMT+0800 (中国标准时间)
 * Author = xiaopang125
 * FileBasename = Dian.ts
 * FileBasenameNoExtension = Dian
 * URL = db://assets/Dian.ts
 * ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
 *
 */

@ccclass('Dian')
export class Dian extends Component {
    rotationNum=0;
    speed=Math.random()+2;
    piNum=Math.random()*2;
    public hd=0;

    

    // [2]
    // @property
    // serializableDummy = 0;

    start() {
        // [3]
        const ctx = this.getComponent(Graphics);
        // ctx.strokeColor.fromHEX('#feed2a');
        ctx.circle(300, 0, 30);
        ctx.fillColor.fromHEX('#feed2a');
        ctx.fill();

    }

    update (deltaTime: number) {
          this.rotationNum-=this.speed;
        // this.node.setRotation(0,0,this.rotationNum,0);
        this.hd=toRadian(this.rotationNum)/Math.PI%2+2;
        // console.log(this.hd%2+2);


        
        this.node.setRotationFromEuler(0,0,this.rotationNum);
        
    }
}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.4/manual/zh/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/zh/scripting/decorator.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/zh/scripting/life-cycle-callbacks.html
 */
